package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class WorksheetCollection extends CollectionBase {
   private boolean m = false;
   int b = 0;
   int c = 1024;
   private Object n = null;
   private zyf o;
   private zavy p;
   HashMap d = new HashMap();
   private HashMap q;
   private int r = 6;
   private NameCollection s;
   private zvh t;
   private boolean u;
   String e;
   private byte v;
   zne f;
   private int w;
   zbpx g;
   private int x;
   private int y;
   static com.aspose.cells.b.a.zh h = new com.aspose.cells.b.a.zh("00020820-0000-0000-c000-000000000046");
   private zus z;
   private StyleCollection A;
   private int B;
   private zbqf C;
   private int D;
   private zyd E;
   private zbmh F;
   private ArrayList G;
   private ArrayList H;
   private DxfCollection I;
   private zbvx J;
   private int K;
   private Style L;
   private XmlMapCollection M;
   private BuiltInDocumentPropertyCollection N;
   private CustomDocumentPropertyCollection O;
   private int P;
   private int Q = (int)com.aspose.cells.a.d.zfq.a();
   private int R = (int)com.aspose.cells.a.d.zfq.a();
   private Object S;
   zbvh i;
   private ExternalLinkCollection T;
   private zra U;
   private zra V;
   private zaul W;
   private zbmv X;
   private zbnd Y;
   private DxfCollection Z;
   private Workbook aa;
   private TableStyleCollection ab;
   private zbnl ac;
   int j = 0;
   private String ad;
   zazw k;
   VbaProject l;

   public boolean isRefreshAllConnections() {
      return this.m;
   }

   public void setRefreshAllConnections(boolean value) {
      this.m = value;
   }

   Object a() {
      return this.n;
   }

   void a(Object var1) {
      this.n = var1;
   }

   zyf b() {
      if (this.o == null) {
         this.o = new zyf(this);
      }

      return this.o;
   }

   zavy c() {
      if (this.p == null) {
         this.p = new zavy(this);
      }

      return this.p;
   }

   HashMap d() {
      if (this.q == null) {
         this.q = new HashMap();

         for(int var1 = 0; var1 < this.getCount(); ++var1) {
            int[] var2 = new int[]{var1, this.z.b(this.B, var1)};
            this.q.put(this.get(var1).getName().toUpperCase(), var2);
         }
      }

      return this.q;
   }

   void e() {
      this.q = null;
   }

   public NameCollection getNames() {
      return this.s;
   }

   zvh f() {
      return this.t;
   }

   void a(zvh var1) {
      this.t = var1;
   }

   boolean g() {
      return this.u;
   }

   void a(boolean var1) {
      this.u = var1;
   }

   String h() {
      return this.e;
   }

   void a(String var1) {
      this.e = var1;
   }

   boolean i() {
      return (this.v & 255 & 1) != 0;
   }

   void b(boolean var1) {
      if (var1) {
         this.v = (byte)(this.v | 1);
      } else {
         this.v = (byte)(this.v & 254);
      }

   }

   boolean j() {
      return (this.v & 255 & 2) != 0;
   }

   void c(boolean var1) {
      if (var1) {
         this.v = (byte)(this.v | 2);
      } else {
         this.v = (byte)(this.v & 253);
      }

   }

   zne k() {
      if (this.f == null) {
         this.f = new zne();
      }

      return this.f;
   }

   void a(WorksheetCollection var1) throws Exception {
      this.q = null;
      this.P = var1.P;
      if (var1.i != null) {
         this.N().a(var1.i);
      }

      this.u = var1.u;
      this.e = var1.e;
      this.v = var1.v;
      this.r = var1.r;
      if (var1.F != null) {
         this.F = new zbmh();
         this.F.a(var1.F);
      } else {
         this.F = null;
      }

      if (var1.U != null) {
         this.U = new zra(this, 0);
         this.U.a(var1.U);
      } else {
         this.U = null;
      }

      if (var1.V != null) {
         this.V = new zra(this, 1);
         this.V.a(var1.V);
      } else {
         this.V = null;
      }

      this.D = var1.D;
      this.x = var1.x;
      this.y = var1.y;
      this.w = var1.w;
      this.K = var1.K;

      int var2;
      for(var2 = 0; var2 < var1.G.size(); ++var2) {
         Font var3 = new Font(this, (Object)null, false);
         Font var4 = (Font)var1.G.get(var2);
         var3.c(var4);
         var3.d(var4.j());
         com.aspose.cells.b.a.a.ze.a(this.G, (Object)var3);
      }

      for(var2 = 0; var2 < var1.H.size(); ++var2) {
         zxw var6 = new zxw();
         zxw var8 = (zxw)var1.H.get(var2);
         var6.a(var8);
         com.aspose.cells.b.a.a.ze.a(this.H, (Object)var6);
      }

      this.J.a(var1.J);
      if (var1.A.getCount() > 0) {
         this.A.a(var1.A);
      }

      Style var7;
      Style var10;
      for(var2 = 0; var2 < var1.getDxfs().getCount(); ++var2) {
         var7 = new Style(this);
         var10 = var1.getDxfs().get(var2);
         var7.copy(var10);
         this.getDxfs().b(var7);
      }

      for(var2 = 0; var2 < var1.Y().getCount(); ++var2) {
         var7 = new Style(this);
         var10 = var1.Y().get(var2);
         var7.copy(var10);
         this.Y().b(var7);
      }

      if (var1.C != null && var1.C.getCount() > 0) {
         if (this.C == null) {
            this.C = new zbqf();
         }

         for(var2 = 0; var2 < var1.C.getCount(); ++var2) {
            zbqg var9 = var1.C.a(var2);
            zbqg var13 = new zbqg();
            var13.a(var9);
            this.C.a(var13);
         }
      }

      this.a.clear();
      this.s.a(var1.s);

      for(var2 = 0; var2 < var1.a.size(); ++var2) {
         Worksheet var11 = (Worksheet)var1.a.get(var2);
         this.c(var11.getName());
      }

      this.z.a(var1.z);
      this.B = var1.B;
      CopyOptions var15 = new CopyOptions(true);

      for(int var12 = 0; var12 < var1.a.size(); ++var12) {
         Worksheet var14 = (Worksheet)var1.a.get(var12);
         Worksheet var5 = this.get(var12);
         var15.setCopyNames(false);
         var5.copy(var14, var15);
      }

      this.t = var1.t;
      if (var1.l != null) {
         this.l = new VbaProject(this.aa, (zane)null, (String)null);
         this.l.a(var1.l);
      }

      this.b = var1.b;
   }

   int l() {
      return this.r;
   }

   zast m() {
      return this.aa.getSettings().c();
   }

   WorksheetCollection(Workbook workbook) {
      this.aa = workbook;
      this.s = new NameCollection(this);
      this.x = 1;
      this.A = new StyleCollection(this);
      this.E = new zyd(this);
      this.G = new ArrayList();
      this.H = new ArrayList();
      this.J = new zbvx(this);
      this.I = new DxfCollection(this);
      this.Z = new DxfCollection(this);
      this.J.b();
      this.K();
      this.g = new zbpx();
      this.T = new ExternalLinkCollection(this);
      this.C = new zbqf();
      zbqg var2 = new zbqg(1);
      this.C.a(var2);
      this.i = null;
   }

   Workbook n() {
      return this.aa;
   }

   public Worksheet get(int index) {
      return (Worksheet)this.a.get(index);
   }

   Worksheet a(int var1) {
      Iterator var2 = this.iterator();

      Worksheet var3;
      do {
         if (!var2.hasNext()) {
            return null;
         }

         var3 = (Worksheet)var2.next();
      } while(var3.l() != var1);

      return var3;
   }

   int b(String var1) {
      for(int var2 = 0; var2 < this.a.size(); ++var2) {
         Worksheet var3 = (Worksheet)this.a.get(var2);
         if (com.aspose.cells.b.a.zv.b(var3.getName().toUpperCase(), var1.toUpperCase())) {
            return var2;
         }
      }

      return -1;
   }

   public Worksheet get(String sheetName) {
      for(int var2 = 0; var2 < this.a.size(); ++var2) {
         Worksheet var3 = (Worksheet)this.a.get(var2);
         if (com.aspose.cells.b.a.zv.b(var3.getName().toUpperCase(), sheetName.toUpperCase())) {
            return var3;
         }
      }

      return null;
   }

   void o() {
      zsu.b(this);
   }

   zack p() {
      int var1 = -1;

      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         if (this.get(var2).isVisible() && var1 == -1) {
            var1 = var2;
         }

         if (this.get(var2).getType() == 2 && this.get(var2).getCharts().getCount() == 0) {
            throw new CellsException(10, "A chart sheet must contain a chart.");
         }
      }

      if (var1 == -1) {
         throw new CellsException(10, "A workbook must contain at least a visible worksheet");
      } else {
         if (!this.get(this.getActiveSheetIndex()).isVisible()) {
            this.setActiveSheetIndex(var1);
         }

         if (this.K >= this.getCount()) {
            this.K = this.getCount() - 1;
         }

         if (!this.get(this.K).isVisible()) {
            for(var1 = this.K + 1; var1 < this.getCount() && !this.get(var1).isVisible(); ++var1) {
               ;
            }

            if (var1 >= this.getCount()) {
               for(var1 = this.K - 1; var1 >= 0 && !this.get(var1).isVisible(); --var1) {
                  ;
               }
            }

            this.K = var1;
         }

         this.ah();
         zack var7 = (new zgr(this.aa, this.aa.getSaveOptions())).a();
         if (this.aa.getSaveOptions().getSortNames()) {
            this.s.sort();
         } else {
            this.s.c();
         }

         for(int var3 = 0; var3 < this.getCount(); ++var3) {
            Worksheet var4 = this.get(var3);
            if (this.aa.getSaveOptions().getValidateMergedAreas()) {
               var4.getCells().j();
            }

            if (this.aa.getSaveOptions().getMergeAreas()) {
               Iterator var5 = var4.getValidations().iterator();

               while(var5.hasNext()) {
                  Validation var6 = (Validation)var5.next();
                  zayd.a(var6.getAreaList());
               }

               var5 = var4.getConditionalFormattings().iterator();

               while(var5.hasNext()) {
                  FormatConditionCollection var8 = (FormatConditionCollection)var5.next();
                  zayd.a(var8.b);
               }
            }

            var4.getListObjects().updateColumnName();
            if (var4.m != null) {
               var4.m.a();
            }
         }

         return var7;
      }
   }

   public Worksheet getSheetByCodeName(String codeName) {
      codeName = codeName.toUpperCase();

      for(int var2 = 0; var2 < this.a.size(); ++var2) {
         Worksheet var3 = (Worksheet)this.a.get(var2);
         if (var3.getCodeName() != null && com.aspose.cells.b.a.zv.b(var3.getCodeName().toUpperCase(), codeName)) {
            return var3;
         }
      }

      return null;
   }

   zus q() {
      return this.z;
   }

   StyleCollection r() {
      return this.A;
   }

   void b(int var1) {
      this.w = var1;
   }

   public int getActiveSheetIndex() {
      return this.w;
   }

   public void setActiveSheetIndex(int value) {
      int var2;
      if (value >= 0 && value < this.getCount()) {
         this.w = value;
         if (value - 5 >= 0) {
            this.K = value - 5;

            for(var2 = this.K; var2 < this.getCount(); ++var2) {
               if (this.get(var2).isVisible()) {
                  this.K = var2;
                  break;
               }
            }
         }
      }

      for(var2 = 0; var2 < this.getCount(); ++var2) {
         if (value != var2) {
            this.get(var2).setSelected(false);
         } else {
            this.get(var2).setSelected(true);
         }
      }

   }

   public void sortNames() {
      this.getNames().sort();
   }

   void c(int var1) {
      this.w = var1;
   }

   void s() {
      Worksheet var1 = new Worksheet(this.g, this, "Sheet1");
      var1.setSelected(true);
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
      this.z = new zus();
      this.z.a(0, 0, 0);
   }

   void t() {
      this.x = 0;
      this.y = 0;
      this.F = new zbmh();
      this.L = null;
      this.a.clear();
      this.z = new zus();
      this.ai();
      this.C.clear();
   }

   public Worksheet insert(int index, int sheetType) {
      this.q = null;

      String var3;
      boolean var4;
      do {
         ++this.x;
         var3 = "Sheet" + this.x;
         var4 = false;

         for(int var5 = 0; var5 < this.getCount(); ++var5) {
            String var6 = this.get(var5).getName();
            if (com.aspose.cells.b.a.zv.b(var6.toUpperCase(), var3.toUpperCase())) {
               var4 = true;
            }
         }
      } while(var4);

      return this.insert(index, sheetType, var3);
   }

   public Worksheet insert(int index, int sheetType, String sheetName) {
      this.q = null;
      Worksheet var4 = null;
      if (index >= this.getCount()) {
         var4 = this.add(sheetName);
         var4.setType(sheetType);
         return var4;
      } else {
         var4 = new Worksheet(this.g, this, sheetName);
         var4.a(sheetName);
         this.a.add(index, var4);
         this.z.c(this.B, index, this.getCount());
         this.getNames().b(index);

         for(int var5 = 0; var5 < this.getCount(); ++var5) {
            Worksheet var6 = this.get(var5);
            var6.d(var5);
         }

         this.setActiveSheetIndex(var4.m());
         return var4;
      }
   }

   public int add(int type) {
      switch(type) {
      case 1:
         return this.add();
      case 2:
         if (this.getCount() >= 65535) {
            throw new CellsException(10, "Too much worksheet objects.");
         }

         Worksheet var2 = new Worksheet(this.g, this);

         String var3;
         boolean var4;
         do {
            ++this.y;
            var3 = "Chart" + this.y;
            var4 = false;

            for(int var5 = 0; var5 < this.getCount(); ++var5) {
               String var6 = this.get(var5).getName();
               if (com.aspose.cells.b.a.zv.b(var6, var3)) {
                  var4 = true;
               }
            }
         } while(var4);

         var2.b(var3);
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var2);
         int var7 = this.a.size() - 1;
         var2.setType(2);
         this.q = null;
         this.z.a(this.B, var7, var7);
         return var7;
      default:
         throw new CellsException(6, "Invalid worksheet type specified.");
      }
   }

   int u() {
      return this.B;
   }

   void d(int var1) {
      this.B = var1;
   }

   void a(int var1, int var2) {
      if (var2 >= 0 && var2 <= this.a.size() - 1) {
         this.q = null;
         Worksheet var3 = this.get(var1);
         if (var2 > var1) {
            this.a.add(var2 + 1, var3);
            this.a.remove(var1);
         } else {
            this.a.add(var2, var3);
            this.a.remove(var1 + 1);
         }

         this.s.a(var1, var2);
         this.z.d(this.B, var1, var2);
      } else {
         throw new IllegalArgumentException();
      }
   }

   public void swapSheet(int sheetIndex1, int sheetIndex2) {
      if (sheetIndex1 >= 0 && sheetIndex1 < this.a.size() && sheetIndex2 >= 0 && sheetIndex2 < this.a.size()) {
         Worksheet var3 = this.get(sheetIndex1);
         Worksheet var4 = this.get(sheetIndex2);
         var3.moveTo(sheetIndex2);
         var4.moveTo(sheetIndex1);
      } else {
         throw new IllegalArgumentException();
      }
   }

   public int add() {
      if (this.getCount() >= 65535) {
         throw new CellsException(10, "Too much worksheet objects.");
      } else {
         Worksheet var1 = new Worksheet(this.g, this);

         String var2;
         boolean var3;
         int var4;
         do {
            ++this.x;
            var2 = "Sheet" + this.x;
            var3 = false;

            for(var4 = 0; var4 < this.getCount(); ++var4) {
               String var5 = this.get(var4).getName();
               if (com.aspose.cells.b.a.zv.b(var5.toUpperCase(), var2.toUpperCase())) {
                  var3 = true;
               }
            }
         } while(var3);

         var1.b(var2);
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
         int var8 = this.a.size() - 1;
         this.q = null;
         var4 = 0;
         if (this.C != null && this.C.getCount() != 0) {
            boolean var9 = false;

            for(int var6 = 0; var6 < this.C.getCount(); ++var6) {
               zbqg var7 = this.C.a(var6);
               if (var7.e()) {
                  var4 = var6;
                  var9 = true;
                  break;
               }
            }

            if (!var9) {
               var4 = this.C.getCount();
            }
         }

         this.z.a(var4, var8, var8);
         return var8;
      }
   }

   public Worksheet add(String sheetName) {
      int var2 = this.add();
      this.get(var2).setName(sheetName);
      this.q = null;
      return this.get(var2);
   }

   int c(String var1) {
      int var2 = this.add();
      this.get(var2).b(var1);
      this.q = null;
      return var2;
   }

   zbqf v() {
      return this.C;
   }

   void a(zbqf var1) {
      this.C = var1;
   }

   int[] a(String var1, boolean var2) {
      int var3 = -1;
      boolean var4 = true;
      int var5 = -1;
      zbqf var6 = this.v();
      boolean var7 = false;
      boolean var8 = false;
      zbqg var9 = null;

      int var10;
      for(var10 = 0; var10 < var6.getCount(); ++var10) {
         var9 = var6.a(var10);
         if (var9.f()) {
            var3 = var10;
            var7 = true;
            break;
         }
      }

      int var12;
      zuk var13;
      if (!var7) {
         if (!var2) {
            return null;
         }

         var9 = new zbqg();
         var9.a(2);
         var13 = new zuk(var9);
         var13.a(var1, false);
         com.aspose.cells.b.a.a.ze.a(var9.b(), (Object)var13);
         var5 = 0;
         this.v().a(var9);
         var12 = this.q().b(this.v().getCount() - 1, 65534, 65534);
      } else {
         var12 = this.q().f(var3, 65534, 65534);
         var7 = true;

         for(var10 = 0; var10 < var9.b().size(); ++var10) {
            zuk var11 = (zuk)var9.b().get(var10);
            if (com.aspose.cells.b.a.zv.b(var11.e().toUpperCase(), var1.toUpperCase())) {
               var5 = var10;
               var8 = true;
               break;
            }
         }

         if (!var8) {
            if (!var2) {
               return null;
            }

            var13 = new zuk(var9);
            var13.a(var1, false);
            com.aspose.cells.b.a.a.ze.a(var9.b(), (Object)var13);
            var5 = var9.b().size() - 1;
         }
      }

      return new int[]{var12, var5};
   }

   int w() {
      return this.D;
   }

   void e(int var1) {
      this.D = var1;
   }

   zyd x() {
      return this.E;
   }

   public void removeAt(String name) {
      name = name.toUpperCase();

      for(int var2 = 0; var2 < this.a.size(); ++var2) {
         Worksheet var3 = (Worksheet)this.a.get(var2);
         if (com.aspose.cells.b.a.zv.b(var3.getName().toUpperCase(), name)) {
            this.removeAt(var2);
            break;
         }
      }

   }

   public void removeAt(int index) {
      this.q = null;
      PivotTableCollection var2;
      int var3;
      if (index < this.getCount()) {
         var2 = this.get(index).getPivotTables();

         for(var3 = 0; var3 < var2.getCount(); ++var3) {
            var2.removeAt(var3);
         }
      }

      var2 = null;

      for(var3 = 0; var3 < this.W().getCount(); ++var3) {
         zbmu var6 = this.W().a(var3);
         if (this.U().a(var6.h) == null) {
            this.W().b(var6);
            --var3;
         }
      }

      var3 = 0;
      int var4;
      if (this.C != null && this.C.getCount() != 0) {
         for(var4 = 0; var4 < this.C.getCount(); ++var4) {
            zbqg var5 = this.C.a(var4);
            if (var5.e()) {
               var3 = var4;
               break;
            }
         }
      }

      zgy.a(this.get(index).getCells(), (zr)this.get(index).getCells().f(), -1, -1);
      this.z.a(index, var3);
      this.a.remove(index);
      this.s.a(index);

      for(var4 = index; var4 < this.getCount(); ++var4) {
         this.get(var4).d(var4);
      }

      if (this.getCount() == 0) {
         this.w = 0;
      } else if (this.w > this.getCount() - 1) {
         this.w = this.getCount() - 1;
      }

      if (this.getCount() == 0) {
         this.K = 0;
      } else if (this.K > this.getCount() - 1) {
         this.K = this.getCount() - 1;
      }

   }

   public void clear() {
      this.a.clear();
      this.x = 0;
   }

   Style f(int var1) {
      return this.J.a(var1);
   }

   Style g(int var1) {
      return var1 != 15 && var1 >= 0 && var1 < this.J.getCount() ? this.J.a(var1) : this.D();
   }

   String h(int var1) {
      for(int var2 = this.H.size() - 1; var2 >= 0; --var2) {
         zxw var3 = (zxw)this.H.get(var2);
         if (var1 == var3.b()) {
            return var3.a();
         }
      }

      return "";
   }

   zxw i(int var1) {
      for(int var2 = this.H.size() - 1; var2 >= 0; --var2) {
         zxw var3 = (zxw)this.H.get(var2);
         if (var1 == var3.b()) {
            return var3;
         }
      }

      return null;
   }

   public int addCopy(String sheetName) throws Exception {
      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         if (com.aspose.cells.b.a.zv.b(this.get(var2).getName(), sheetName)) {
            return this.addCopy(var2);
         }
      }

      throw new CellsException(15, "Invalid worksheet name.");
   }

   public int addCopy(int sheetIndex) throws Exception {
      if (sheetIndex >= 0 && sheetIndex <= this.a.size() - 1) {
         this.n().b();
         int var2 = this.add();
         Worksheet var3 = this.get(var2);
         Worksheet var4 = (Worksheet)this.a.get(sheetIndex);
         var3.copy(var4);
         return var2;
      } else {
         throw new IllegalArgumentException("Parameter name: Invalid sheet index.");
      }
   }

   void b(WorksheetCollection var1) throws Exception {
      this.q = null;
      int var2 = this.getCount();

      for(int var3 = 0; var3 < var1.getCount(); ++var3) {
         String var4 = var1.get(var3).getName();
         if (this.get(var4) != null) {
            var4 = zakq.a(this, var4);
         }

         this.c(var4);
      }

      HashMap var10 = new HashMap();
      int var11 = this.q().f(this.u(), 65535, 65535);
      if (var11 == -1) {
         var11 = this.q().b(this.u(), 65535, 65535);
      }

      int[] var5 = var1.q().c(var1.u(), -1);

      int var6;
      for(var6 = 0; var6 < var5.length; ++var6) {
         var10.put(var5[var6], var11);
      }

      int var8;
      for(var6 = 0; var6 < var1.getCount(); ++var6) {
         int var7 = var6 + var2;
         var5 = var1.q().c(var1.u(), var6);
         var8 = this.q().b(this.u(), var7);

         for(int var9 = 0; var9 < var5.length; ++var9) {
            var10.put(var5[var9], var8);
         }
      }

      HashMap var12 = new HashMap();
      this.a(var2, var1, var10, var11, var12);
      CopyOptions var13 = new CopyOptions(false);
      var13.setCopyNames(false);
      var13.i = var10;
      var13.d = var12;
      var13.k = new HashMap();
      var13.c = 6;

      for(var8 = 0; var8 < var1.getCount(); ++var8) {
         this.get(var8 + var2).copy(var1.get(var8), var13);
      }

   }

   void a(int var1, WorksheetCollection var2, HashMap var3, int var4, HashMap var5) {
      if (var2.s != null && var2.s.getCount() > 0) {
         HashMap var6 = new HashMap();
         var6.put(-1, -1);

         int var7;
         for(var7 = 0; var7 < var2.getCount(); ++var7) {
            int var8 = var7 + var1;
            var6.put(var7, var8);
         }

         for(var7 = 0; var7 < var2.s.getCount(); ++var7) {
            Name var14 = var2.s.get(var7);
            int var9 = var14.getSheetIndex() - 1;
            String var10 = var14.getText();
            int var11;
            if (var9 == -1 && this.getNames().a(var10, var9, false) != -1) {
               var11 = var14.o();
               if (var11 >= 0 && var11 < var2.getCount() && var11 != var9) {
                  var9 = var11;
               } else {
                  var10 = var10 + "_1";
               }
            }

            var11 = -1;
            if (var9 != -1) {
               var11 = (Integer)var6.get(var9);
            }

            int var12 = this.getNames().a(var11, var10);
            Name var13 = this.getNames().get(var12);
            var13.a(var14, var3, var4);
            var5.put(var7, var12);
         }
      }

   }

   zbmh y() {
      return this.F;
   }

   ArrayList z() {
      return this.G;
   }

   Font j(int var1) {
      return (Font)this.z().get(var1 > 4 ? var1 - 1 : var1);
   }

   Font k(int var1) {
      if (var1 < 0) {
         return null;
      } else {
         if (var1 > 4) {
            --var1;
         }

         return var1 >= this.G.size() ? null : (Font)this.z().get(var1);
      }
   }

   ArrayList A() {
      return this.H;
   }

   public DxfCollection getDxfs() {
      return this.I;
   }

   zbvx B() {
      return this.J;
   }

   int a(Style var1) {
      return this.J.c(var1);
   }

   private void ah() {
      this.getDxfs().a();

      for(int var1 = this.J.getCount() - 1; var1 > -1; --var1) {
         Style var2 = this.J.a(var1);
         if (var2 != null) {
            this.c(var2);
            if (var2.getCustom() != null && !"".equals(var2.getCustom())) {
               var2.d(this.d(var2.getCustom()));
            }
         }
      }

      this.aj();
      this.ak();
   }

   private void ai() {
      this.J.clear();
      this.G.clear();
      this.H.clear();
      this.A.a();
   }

   private void c(Style var1) {
      boolean var2 = false;

      for(int var3 = 0; var3 < this.G.size(); ++var3) {
         Font var4 = (Font)this.G.get(var3);
         if (var1.getFont().a(var4)) {
            if (var3 < 4) {
               var1.getFont().d(var3);
            } else {
               var1.getFont().d(var3 + 1);
            }

            var2 = true;
            break;
         }
      }

      if (!var2) {
         com.aspose.cells.b.a.a.ze.a(this.G, (Object)var1.getFont());
         var1.getFont().d(this.G.size());
      }

   }

   void a(Font var1) {
      boolean var2 = false;

      for(int var3 = 0; var3 < this.G.size(); ++var3) {
         Font var4 = (Font)this.G.get(var3);
         if (var1.a(var4)) {
            if (var3 < 4) {
               var1.d(var3);
            } else {
               var1.d(var3 + 1);
            }

            var2 = true;
            break;
         }
      }

      if (!var2) {
         com.aspose.cells.b.a.a.ze.a(this.G, (Object)var1);
         var1.d(this.G.size());
      }

   }

   int b(Font var1) {
      int var2;
      for(var2 = 0; var2 < this.G.size(); ++var2) {
         Font var3 = (Font)this.G.get(var2);
         if (var1.a(var3)) {
            if (var2 < 4) {
               return var2;
            }

            return var2 + 1;
         }
      }

      var2 = com.aspose.cells.b.a.a.ze.a(this.G, (Object)var1);
      if (var2 < 4) {
         return var2;
      } else {
         return var2 + 1;
      }
   }

   int d(String var1) {
      for(int var2 = 0; var2 < this.H.size(); ++var2) {
         zxw var3 = (zxw)this.H.get(var2);
         if (com.aspose.cells.b.a.zv.b(var1, var3.a())) {
            return var3.b();
         }
      }

      if ((this.D & '\uffff') < 176) {
         this.D = 176;
      }

      ++this.D;
      zxw var4 = new zxw();
      var4.a(var1, this.D);
      com.aspose.cells.b.a.a.ze.a(this.H, (Object)var4);
      return this.D;
   }

   private void aj() {
      for(int var1 = 0; var1 < this.getCount(); ++var1) {
         Worksheet var2 = (Worksheet)this.a.get(var1);
         CommentCollection var3 = var2.getComments();
         int var5 = 0;
         Font var4;
         if (var3.getCount() != 0) {
            var4 = new Font(this, (Object)null, true);
            var4.setSize(8);
            var4.setBold(true);
            this.a(var4);
            var5 = var4.j();
         }

         for(int var6 = 0; var6 < var3.getCount(); ++var6) {
            Comment var7 = var3.get(var6);
            if (var7.d() != null) {
               var4 = var7.getFont();
               this.a(var4);
               var7.c(var4.j());
            } else {
               var7.c(var5);
            }

            if (var7.b().p() != null && var7.b().p().size() != 0) {
               Iterator var8 = var7.b().p().iterator();

               while(var8.hasNext()) {
                  FontSetting var9 = (FontSetting)var8.next();
                  if (var9.c() != null) {
                     this.a(var9.c());
                  }
               }
            }
         }

         if (var2.getType() == 2) {
            var2.getCharts().get(0).a(this.G);
         } else if (var2.t() != null) {
            var2.getShapes().b();
         }
      }

   }

   private void ak() {
      for(int var1 = 0; var1 < this.getDxfs().getCount(); ++var1) {
         Style var2 = this.getDxfs().get(var1);
         if (var2.isModified(24)) {
            String var3 = var2.getCustom();
            if (var3 != null && !"".equals(var3)) {
               var2.d(this.d(var3));
            }
         }
      }

      Iterator var8 = this.a.iterator();

      label107:
      while(true) {
         Iterator var5;
         Worksheet var9;
         Iterator var10;
         do {
            label79:
            do {
               if (!var8.hasNext()) {
                  return;
               }

               var9 = (Worksheet)var8.next();
               if (this.aa.e != 6) {
                  var10 = var9.getCharts().iterator();

                  while(true) {
                     Chart var4;
                     do {
                        do {
                           if (!var10.hasNext()) {
                              continue label79;
                           }

                           var4 = (Chart)var10.next();
                           var4.C();
                        } while(var4.l() == null);
                     } while(var4.getShapes().getCount() <= 0);

                     var5 = var4.getShapes().iterator();

                     while(var5.hasNext()) {
                        Shape var6 = (Shape)var5.next();
                        if (var6.getMsoDrawingType() == 5) {
                           ((ChartShape)var6).a().C();
                        }
                     }
                  }
               }
            } while(var9.b == null);
         } while(var9.b.getCount() <= 0);

         var10 = var9.b.iterator();

         while(true) {
            String var7;
            PivotTable var11;
            PivotField var12;
            do {
               if (!var10.hasNext()) {
                  continue label107;
               }

               var11 = (PivotTable)var10.next();
               if (var11.getDataFields().getCount() > 0) {
                  var5 = var11.getDataFields().a.iterator();

                  while(var5.hasNext()) {
                     var12 = (PivotField)var5.next();
                     var7 = var12.getNumberFormat();
                     if (var7 != null && !"".equals(var7)) {
                        var12.c(this.d(var7));
                     }
                  }
               }
            } while(var11.getBaseFields().getCount() <= 0);

            var5 = var11.getBaseFields().a.iterator();

            while(var5.hasNext()) {
               var12 = (PivotField)var5.next();
               var7 = var12.getNumberFormat();
               if (var7 != null && !"".equals(var7)) {
                  var12.c(this.d(var7));
               }
            }
         }
      }
   }

   public Range getRangeByName(String rangeName) {
      int var3 = -1;
      int var4 = rangeName.indexOf("!");
      if (var4 != -1) {
         String var5 = rangeName.substring(0, 0 + var4);
         if (var5 == null || "".equals(var5)) {
            return null;
         }

         if (var5.charAt(0) == '\'') {
            var5 = var5.substring(1, 1 + (var5.length() - 2));
         }

         int var6 = 0;

         while(true) {
            if (var6 < this.getCount()) {
               if (!com.aspose.cells.b.a.zv.b(var5, this.get(var6).getName())) {
                  ++var6;
                  continue;
               }

               var3 = var6;
            }

            if (var3 == -1) {
               return null;
            }

            rangeName = rangeName.substring(var4 + 1);
            if (rangeName == null || "".equals(rangeName)) {
               return null;
            }
            break;
         }
      }

      Name var2 = this.s.a(rangeName, var3);
      if (var2 == null) {
         return null;
      } else {
         return var2.s();
      }
   }

   Range b(String var1, boolean var2) {
      int var4 = -1;
      int var5 = var1.indexOf("!");
      if (var5 != -1) {
         String var6 = var1.substring(0, 0 + var5);
         if (var6 == null || "".equals(var6)) {
            return null;
         }

         if (var6.charAt(0) == '\'') {
            var6 = var6.substring(1, 1 + (var6.length() - 2));
         }

         int var7 = 0;

         while(true) {
            if (var7 < this.getCount()) {
               if (!com.aspose.cells.b.a.zv.b(var6, this.get(var7).getName())) {
                  ++var7;
                  continue;
               }

               var4 = var7;
            }

            if (var4 == -1) {
               return null;
            }

            var1 = var1.substring(var5 + 1);
            if (var1 == null || "".equals(var1)) {
               return null;
            }
            break;
         }
      }

      Name var3 = this.s.a(var1, var4);
      if (var3 != null) {
         return var3.s();
      } else {
         if (var2) {
            var1 = var1.toLowerCase();

            for(int var11 = 0; var11 < this.getCount(); ++var11) {
               ListObjectCollection var12 = this.get(var11).getListObjects();
               if (var12.getCount() > 0) {
                  for(int var8 = 0; var8 < var12.getCount(); ++var8) {
                     ListObject var9 = var12.get(var8);
                     if (com.aspose.cells.b.a.zv.b(var9.getDisplayName().toLowerCase(), var1)) {
                        Range var10 = new Range(var9.getStartRow(), var9.getStartColumn(), var9.getEndRow() - var9.getStartRow() + 1, var9.getEndColumn() - var9.getStartColumn() + 1, this.get(var11).getCells());
                        var10.a(var9.getDisplayName());
                        var10.b = var9;
                        return var10;
                     }
                  }
               }
            }
         }

         return null;
      }
   }

   Range e(String var1) {
      if (var1 != null && !var1.equals("")) {
         String var2 = null;
         int var5;
         int var8;
         if (var1.charAt(0) == '\'') {
            char[] var3 = var1.toCharArray();
            int var4 = 0;

            for(var5 = 1; var5 < var3.length; ++var5) {
               if (var3[var5] == '\'') {
                  ++var5;
                  if (var5 == var3.length) {
                     break;
                  }

                  if (var3[var5] != '\'') {
                     if (var3[var5] == '!') {
                        if (var5 == var3.length - 1) {
                           return null;
                        }

                        var2 = new String(var3, 0, var4);
                        var1 = var1.substring(var5 + 1);
                     }
                     break;
                  }

                  var3[var4++] = '\'';
               } else {
                  var3[var4++] = var3[var5];
               }
            }
         } else {
            var8 = var1.indexOf("!");
            if (var8 == 0) {
               return null;
            }

            if (var8 > 0) {
               if (var8 == var1.length() - 1) {
                  return null;
               }

               var2 = var1.substring(0, 0 + var8);
               var1 = var1.substring(var8 + 1);
            }
         }

         if (var2 != null) {
            for(var8 = 0; var8 < this.getCount(); ++var8) {
               if (com.aspose.cells.b.a.zv.b(var2, this.get(var8).getName())) {
                  var2 = null;
                  break;
               }
            }

            if (var2 != null) {
               return null;
            }
         }

         var1 = var1.toLowerCase();

         for(var8 = this.getCount() - 1; var8 > -1; --var8) {
            ListObjectCollection var9 = this.get(var8).getListObjects();
            if (var9.getCount() > 0) {
               for(var5 = var9.getCount() - 1; var5 > -1; --var5) {
                  ListObject var6 = var9.get(var5);
                  if (com.aspose.cells.b.a.zv.b(var6.getDisplayName().toLowerCase(), var1)) {
                     Range var7 = new Range(var6.getStartRow(), var6.getStartColumn(), var6.getEndRow() - var6.getStartRow() + 1, var6.getEndColumn() - var6.getStartColumn() + 1, this.get(var8).getCells());
                     var7.a(var6.getDisplayName());
                     var7.b = var6;
                     return var7;
                  }
               }
            }
         }

         return null;
      } else {
         return null;
      }
   }

   public Range[] getNamedRanges() {
      return this.s.getCount() == 0 ? null : this.s.a(this);
   }

   public Range[] getNamedRangesAndTables() {
      ArrayList var1 = new ArrayList();
      Range[] var2;
      if (this.s.getCount() != 0) {
         var2 = this.s.a(this);
         if (var2 != null) {
            com.aspose.cells.b.a.a.ze.b(var1, var2);
         }
      }

      for(int var7 = 0; var7 < this.getCount(); ++var7) {
         ListObjectCollection var3 = this.get(var7).getListObjects();
         if (var3.getCount() > 0) {
            for(int var4 = 0; var4 < var3.getCount(); ++var4) {
               ListObject var5 = var3.get(var4);
               Range var6 = new Range(var5.getStartRow(), var5.getStartColumn(), var5.getEndRow() - var5.getStartRow() + 1, var5.getEndColumn() - var5.getStartColumn() + 1, this.get(var7).getCells());
               var6.a(var5.f());
               com.aspose.cells.b.a.a.ze.a(var1, (Object)var6);
            }
         }
      }

      if (var1.size() == 0) {
         return null;
      } else {
         var2 = new Range[var1.size()];
         com.aspose.cells.b.a.a.ze.a(var1, (Object[])var2);
         return var2;
      }
   }

   int C() {
      return this.K;
   }

   void l(int var1) {
      this.K = var1;
   }

   Style D() {
      if (this.L == null) {
         this.L = new Style(this);
         this.L.a((WorksheetCollection)this, (int)15);
      }

      return this.L;
   }

   void b(Style var1) {
      this.L = var1;
      var1.a(this);
      this.J.a(15, var1);
      Style var2 = this.J.a(0);
      var2.copy(var1);
      this.G.set(0, var2.getFont());
      var2.a(false);
      var2.a((byte)-1);
      var2.a((int)4095);
      this.K();
   }

   public XmlMapCollection getXmlMaps() {
      if (this.M == null) {
         this.M = new XmlMapCollection();
      }

      return this.M;
   }

   public void setXmlMaps(XmlMapCollection value) {
      this.M = value;
   }

   BuiltInDocumentPropertyCollection E() {
      return this.N;
   }

   public BuiltInDocumentPropertyCollection getBuiltInDocumentProperties() {
      if (this.N == null) {
         this.N = new BuiltInDocumentPropertyCollection();
      }

      return this.N;
   }

   CustomDocumentPropertyCollection F() {
      return this.O;
   }

   public CustomDocumentPropertyCollection getCustomDocumentProperties() {
      if (this.O == null) {
         this.O = new CustomDocumentPropertyCollection(this);
      }

      return this.O;
   }

   Font G() {
      return this.J.a(15).getFont();
   }

   int H() {
      return (int)((double)this.J() * 1.0D / (double)this.P * 256.0D);
   }

   int I() {
      return this.P;
   }

   int J() {
      return 5;
   }

   void K() {
      int[] var1 = zbpt.a(this);
      this.P = var1[2];

      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         this.get(var2).l = null;
      }

   }

   int L() {
      return this.Q;
   }

   int M() {
      return this.R;
   }

   public Object getOleSize() {
      return this.S;
   }

   public void setOleSize(Object value) {
      this.S = value;
   }

   public void setOleSize(int startRow, int endRow, int startColumn, int endColumn) {
      CellArea var5 = new CellArea();
      var5.StartRow = startRow;
      var5.EndRow = endRow;
      var5.StartColumn = startColumn;
      var5.EndColumn = endColumn;
      this.S = var5;
   }

   void f(String var1) {
      int var2 = 0;
      if (this.i != null) {
         var2 = this.i.b();
      }

      if (var1 != null && !"".equals(var1)) {
         if ((var2 & '\uffff') != 0) {
            int var3 = zsw.a(var1);
            if (var2 != var3) {
               throw new CellsException(8, "Invalid password.");
            }
         }
      } else if ((var2 & '\uffff') != 0) {
         throw new CellsException(8, "This workbook is protected with password.");
      }

      this.i = null;
   }

   zbvh N() {
      if (this.i == null) {
         this.i = new zbvh();
      }

      return this.i;
   }

   private void b(int var1, String var2) {
      zbvh var3 = null;
      switch(var1) {
      case 0:
         var3 = this.N();
         var3.b = var3.a = true;
         break;
      case 4:
         var3 = this.N();
         var3.b = true;
         var3.a = false;
         break;
      case 5:
         var3 = this.N();
         var3.b = false;
         var3.a = true;
         break;
      default:
         return;
      }

      if (var2 != null && !"".equals(var2)) {
         var3.a(zsw.a(var2));
      } else {
         var3.a(0);
      }

   }

   int O() {
      if (this.i == null) {
         return 6;
      } else if (this.i.b) {
         return this.i.a ? 0 : 4;
      } else {
         return this.i.a ? 5 : 6;
      }
   }

   void a(int var1, String var2) {
      switch(var1) {
      case 1:
      case 2:
      case 3:
         return;
      default:
         if (this.i != null && (this.i.b() & '\uffff') != 0) {
            if (this.P()) {
               throw new CellsException(6, "This workbook is already protected, please unprotected it first.");
            }

            this.b(var1, var2);
         } else {
            this.b(var1, var2);
         }

      }
   }

   public ExternalLinkCollection getExternalLinks() {
      return this.T;
   }

   boolean P() {
      if (this.i == null) {
         return false;
      } else {
         return this.i.b || this.i.a;
      }
   }

   zra Q() {
      if (this.U == null) {
         this.U = new zra(this, 0);
      }

      return this.U;
   }

   zra R() {
      return this.U;
   }

   void a(zra var1) {
      this.U = var1;
   }

   zra S() {
      if (this.V == null) {
         this.V = new zra(this, 1);
      }

      return this.V;
   }

   zra T() {
      return this.V;
   }

   zaul U() {
      if (this.W == null) {
         this.W = new zaul(this);
      }

      return this.W;
   }

   zaul V() {
      return this.W;
   }

   zbmv W() {
      if (null == this.X) {
         this.X = new zbmv(this);
      }

      return this.X;
   }

   zbnd X() {
      if (null == this.Y) {
         this.Y = new zbnd(this);
      }

      return this.Y;
   }

   DxfCollection Y() {
      if (null == this.Z) {
         this.Z = new DxfCollection(this);
      }

      return this.Z;
   }

   TableStyleCollection Z() {
      return this.ab;
   }

   public TableStyleCollection getTableStyles() {
      if (this.ab == null) {
         this.ab = new TableStyleCollection(this);
      }

      return this.ab;
   }

   zbnl aa() {
      if (this.ac == null) {
         this.ac = new zbnl();
      }

      return this.ac;
   }

   zbnl ab() {
      return this.ac;
   }

   String ac() {
      if (this.ad == null) {
         this.ad = com.aspose.cells.a.c.zo.a();
      }

      return this.ad;
   }

   void ad() {
      for(int var1 = 0; var1 < this.s.getCount(); ++var1) {
         Name var2 = this.s.get(var1);
         var2.m();
      }

   }

   void ae() {
      int var1;
      for(var1 = 0; var1 < this.s.getCount(); ++var1) {
         Name var2 = this.s.get(var1);
         if (var2.b.a != null) {
            var2.b.a.a((zaar)null);
         }
      }

      if (this.C != null) {
         for(var1 = this.C.getCount() - 1; var1 > -1; --var1) {
            zbqg var6 = this.C.a(var1);
            if (!var6.e()) {
               ArrayList var3 = var6.b();

               for(int var4 = var3.size() - 1; var4 > -1; --var4) {
                  zuk var5 = (zuk)var3.get(var4);
                  if (var5.a.a != null) {
                     var5.a.a.a((zaar)null);
                  }
               }
            }
         }
      }

   }

   zazw af() {
      if (this.k == null) {
         this.k = new zazw(this.aa);
      }

      return this.k;
   }

   VbaProject ag() throws Exception {
      if (this.l != null) {
         try {
            this.l.b();
         } catch (Exception var2) {
            ;
         }
      }

      return this.l;
   }
}
